﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CaptureVision.Sunflower
{
   
    /// <summary>
    /// Generic Sunflow Property.
    /// </summary>
    /// <typeparam name="TPropertyType"></typeparam>
    public abstract class TypedSunflowProperty<TPropertyType> : SunFlowProperty
    {
        protected IDictionary<string, TPropertyType> _values;

        /// <summary>
        /// Initializes a new instance of 
        /// the <see cref="TypedSunflowProperty&lt;TPropertyType&gt;"/> class.
        /// </summary>
        /// <param name="propertyName">The name.</param>
        protected TypedSunflowProperty(string propertyName)
        {
            Name = propertyName;
            _values = new Dictionary<string, TPropertyType>();        
        }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        public string Name { get; set; }



        /// <summary>
        /// Gets the scene token.
        /// </summary>
        /// <returns>the scene token.</returns>
        public override string GetSceneFileTokenString()
        {
            var sb = new StringBuilder();
           
            // Appends the property Name..
            sb.Append(Name);

            // Appends the property values.
            foreach (var propertyType in _values)
            {
                sb.AppendFormat(" {1} ", propertyType.Key, propertyType.Value.ToString().Replace(",","."));

            }
            //sb.Append(CRLF);

            return sb.ToString();

        }

        
    }
}
